﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ReceiptReason.ascx.cs" Inherits="ERP.Modules.ReceiptReason" %>
<ext:Hidden ID="FormatTypeReceiptReason" runat="server" />
<%--------------GridReceiptReason-----------------%>
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelReceiptReason">
    <Content>
        <ext:GridPanel
            ID="grReceiptReason"
            runat="server"
            Cls="grid-double"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <ext:Store
                    ID="StoreReceiptReason"
                    runat="server"
                    OnReadData="StoreReceiptReason_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model runat="server" IDProperty="ID" GroupField="AccountLevel2_Name_Code_Have">
                            <Fields>
                                <ext:ModelField Name="ReceiptReasonCode" Type="String" />
                                <ext:ModelField Name="ReceiptReasonName" Type="String" />
                                <ext:ModelField Name="Debt" Type="Int" />
                                <ext:ModelField Name="Have" Type="Int" />
                                <ext:ModelField Name="AccountLevel2_Name_Code_Debt" Type="String" />
                                <ext:ModelField Name="AccountLevel2_Name_Code_Have" Type="String" />
                                <ext:ModelField Name="IsActive" Type="Boolean" />
                                <ext:ModelField Name="Note" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                    <ext:Column runat="server" Text="Mã phương thức thu" Width="200" DataIndex="ReceiptReasonCode"></ext:Column>
                    <ext:Column runat="server" Text="Tên phương thức thu" Width="200" DataIndex="ReceiptReasonName"></ext:Column>
                    <ext:Column runat="server" Text="Tài khoản có" Width="150" DataIndex="AccountLevel2_Name_Code_Have"></ext:Column>
                    <ext:Column runat="server" Text="Tài khoản nợ" Width="150" DataIndex="AccountLevel2_Name_Code_Debt"></ext:Column>
                    <ext:CheckColumn runat="server" Text="Trạng thái" Width="150" DataIndex="IsActive" Align="Center"></ext:CheckColumn>
                    <ext:Column runat="server" Text="Ghi chú" Width="100" DataIndex="Note" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping
                    runat="server" 
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="ReceiptReasonDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="ID" Value="record.data.ID" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                    <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <View>
                <ext:GridView runat="server" StripeRows="true" />
            </View>
            <DockedItems>
                <ext:Toolbar runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grReceiptReason}, #{FormatTypeReceiptReason}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>

                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event"></TriggerClick>
                                 <SpecialKey OnEvent="Search_Event" Before="return e.getKey() == Ext.EventObject.ENTER;">
                                     <EventMask ShowMask="true" Msg="Đang tải..." />
                                </SpecialKey>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar runat="server" StoreID="StoreReceiptReason" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsReceiptReason-----------------%>
        <ext:Window ID="WindowsReceiptReason" runat="server"
            Title="Cập nhật phương thức phiếu chi"
            Width="381px"
            Height="379px"
            Hidden="true"
            Region="Center"
            Modal="true"
            HideMode="Display"
            Border="false"
            Padding="5"
            DefaultButton="btnSavePopUp"
            Resizable="false">
            <Items>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelReceiptReason}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField ID="txtReceiptReason_ID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                        <ext:TextField ID="txtIDHave" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                        <ext:TextField ID="txtIDDebt" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                    </Items>
                </ext:Toolbar>
                <ext:FormPanel ID="FormPanelReceiptReason" runat="server"
                    AutoHeight="true"
                    BodyPadding="10"
                    Frame="true">
                    <Items>
                        <ext:TextField ID="txtReceiptReason_Alias" runat="server" LabelAlign="Top" FieldLabel="Mã phương thức thu" AnchorHorizontal="100%" AllowBlank="False" />
                        <ext:TextField ID="txtReceiptReason_Name" runat="server" LabelAlign="Top" FieldLabel="Tên phương thức thu" AnchorHorizontal="100%" AllowBlank="False" />
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtHave" ReadOnly="True" runat="server" LabelAlign="Top" FieldLabel="Tài khoản có" Width="310px" AllowBlank="True" />
                                <ext:Button runat="server" Text="" Icon="BulletGet" ID="btnHave" ToolTip="Đến danh sách" Margins="18 8 0 5">
                                    <DirectEvents>
                                        <Click OnEvent="btnHave_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:FieldContainer>
                        
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtDebt" ReadOnly="True" runat="server" LabelAlign="Top" FieldLabel="Tài khoản nợ" Width="310px" AllowBlank="True" />
                                <ext:Button runat="server" Text="" Icon="BulletGet" ID="btnDebt" ToolTip="Đến danh sách" Margins="18 8 0 5">
                                    <DirectEvents>
                                        <Click OnEvent="btnDebt_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                          </ext:FieldContainer>
                        <ext:Checkbox runat="server" ID="chkIsActive" LabelAlign="Top" FieldLabel="Active" AnchorHorizontal="100%"></ext:Checkbox>
                       <ext:TextArea ID="txtReceiptReason_Note" LabelAlign="Top" runat="server" FieldLabel="Ghi chú" AnchorHorizontal="100%" />
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        <%-------------WindowsAccounting------------------%>
        <ext:Window ID="WindowsAccounting" runat="server"
            Title="Thông tin tài khoản"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grAssignedAccountingHave"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <ext:Store
                            ID="StoreAssignedAccountLevelHave"
                            runat="server"
                            OnReadData="StoreAssignedAccountingHave_RefreshData"
                            PageSize="20">
                            <Model>
                                <ext:Model runat="server" IDProperty="IDAccountLevel2" GroupField="AccountLevel1_Name">
                                    <Fields>
                                        <ext:ModelField Name="AccountLevel2_Name_Code" Type="String" />
                                        <ext:ModelField Name="AccountLevel2_Name" Type="String" />
                                        <ext:ModelField Name="Note" Type="String" />
                                        <ext:ModelField Name="AccountLevel1_Name_Code" Type="String" />
                                        <ext:ModelField Name="AccountLevel1_Name" Type="String" />
                                        <ext:ModelField Name="Income_Expenditure_Method_Name" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                            <ext:Column runat="server" Text="Mã tài khoản cấp 1" Width="150" DataIndex="AccountLevel1_Name_Code"></ext:Column>
                            <ext:Column runat="server" Text="Tên tài khoản cấp 1" Width="200" DataIndex="AccountLevel1_Name"></ext:Column>
                            <ext:Column runat="server" Text="Mã tài khoản cấp 2" Width="150" DataIndex="AccountLevel2_Name_Code"></ext:Column>
                            <ext:Column runat="server" Text="Tên tài khoản cấp 2" Width="200" DataIndex="AccountLevel2_Name"></ext:Column>
                            <ext:Column runat="server" Text="Loại tài khoản" Width="100" DataIndex="Income_Expenditure_Method_Name"></ext:Column>
                            <ext:Column runat="server" Text="Ghi chú" Width="100" DataIndex="Note" Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <Features>
                    <ext:Grouping
                        runat="server"
                        HideGroupedHeader="true"
                        GroupByText="Xem theo phân nhóm"
                        ShowGroupsText="Phân nhóm"
                        GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                        StartCollapsed="True" />
                    </Features>
                    <SelectionModel>
                        <ext:CellSelectionModel runat="server">
                            <DirectEvents>
                                <Select OnEvent="CellAssignedAccountingHave_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Select>
                            </DirectEvents>
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:TriggerField ID="txtSearchAccountHave" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Search" />
                                    </Triggers>
                                    <DirectEvents>
                                        <TriggerClick OnEvent="AccountingHaveSearch_Event"></TriggerClick>
                                        <KeyPress OnEvent="AccountingHaveSearch_Event"></KeyPress>
                                        <KeyUp OnEvent="AccountingHaveSearch_Event"></KeyUp>
                                    </DirectEvents>
                                </ext:TriggerField>
                                <ext:PagingToolbar runat="server" StoreID="StoreAssignedAccountLevelHave" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
    </Content>
</ext:Panel>